/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.edu.com1263.model;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 *
 * @author Luiz Cardoso
 */
@Entity
@Table(name="turma")
public class Turma implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8455495435314936570L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="id_turma")
    private Long id;
    
    @Column(name="cod_turma")
	String codTurma;
  	
	@Column(name="ano_periodo", nullable=false)
    String anoPeriodo;
    
	@ManyToMany
	@JoinTable(name = "aluno_turma", 
			joinColumns = { @JoinColumn(name = "id_turma") }, 
			inverseJoinColumns = { @JoinColumn(name = "id_aluno") })
	private Collection<Aluno> alunos;
    
    @ManyToOne
	@JoinColumn(name = "id_prof")
	private Professor professor;
    
    @ManyToOne
	@JoinColumn(name = "id_disc")
	private Disciplina disciplina;
    
    @ManyToOne
	@JoinColumn(name = "id_horario")
	private Horario horario;
    
    @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "turma")
	private Collection<Tarefa> tarefas;
    
    public Horario getHorario() {
		return horario;
	}

	public void setHorario(Horario horario) {
		this.horario = horario;
	}

    public Turma() {
    	alunos = new HashSet<Aluno>();
    }

	public Turma(String codTurma, String anoPeriodo) {
		this.codTurma = codTurma;
		this.anoPeriodo = anoPeriodo;
    	setTarefas(new HashSet<Tarefa>());
	
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Collection<Aluno> getAlunos() {
		return alunos;
	}

	public void setAlunos(Collection<Aluno> alunos) {
		this.alunos = alunos;
	}

	public Disciplina getDisciplina() {
		return disciplina;
	}

	public void setDisciplina(Disciplina disciplina) {
		this.disciplina = disciplina;
	}

	public Professor getProfessor() {
		return professor;
	}

	public void setProfessor(Professor professor) {
		this.professor = professor;
	}

	public String getAnoPeriodo() {
		return anoPeriodo;
	}

	public void setAnoPeriodo(String anoPeriodo) {
		this.anoPeriodo = anoPeriodo;
	}

	public Collection<Tarefa> getTarefas() {
		return tarefas;
	}

	public void setTarefas(Collection<Tarefa> tarefas) {
		this.tarefas = tarefas;
	}

	public String getCodTurma() {
		return codTurma;
	}

	public void setCodTurma(String codTurma) {
		this.codTurma = codTurma;
	}

    
}
